<template>
  <div class="list">
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{path:'/'}">首页</el-breadcrumb-item>
      <el-breadcrumb-item><a href="/complaint/list">违规投诉列表页</a></el-breadcrumb-item>
      <el-breadcrumb-item>投诉详情页</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="content">
      <h1 class="title" style="font-size: 24px;">{{ title }}</h1>
      <div class="publish">
        <span style="color: #333;font-size: 14px;">创建时间：</span>
        <span style="color: #666;font-size: 14px;">{{ publishDataTime }}</span>
      </div>
      <div class="status" :style="[{color:(statusVal==='0'?'#E4931B':'#3D3D3D')}]"> {{ getStatusValue(statusVal) }}</div>
      <div class="bidContent" ref="bidContent" style="text-align: left;"></div>
      <div class="download">
        <li v-for="item in fileList" @click="downFile(item.fileName)">
          <span>附件：</span>
          <span>{{ item.fileName }}</span>
        </li>
      </div>
    </div>
  </div>
</template>

<script>
import {getComplaint} from '@/api/bid/complaint'
import {download} from '@/utils/neu'

export default {
  name: "detail",
  methods: {
    downFile(fileName){
      download(fileName)
    },
    getStatusValue(key) {
      const values = this.status.filter(x => x.key === key);
      if (values && values.length > 0) {
        return values[0].value
      }
      return ''
    }
  },
  data() {
    return {
      id:'',
      title:'',
      publisher:'',
      publishDataTime:'',
      bidContent:'',
      fileList:[],
      bidFiles: [],
      status: [{
        key: "0",
        value: '正在处理中'
      }, {
        key: "1",
        value: '处理完成'
      }],
      statusVal: ""
    }
  },
  async created() {
   this.id = this.$route.query.id
  },
  mounted() {
    getComplaint(this.id).then(res=>{
      console.log(res);
      this.title = res.data.title
      this.publishDataTime = this.parseTime(res.data.createTime,'{y}年{m}月{d}日')
      this.bidContent = res.data.content
      this.fileList = res.data.filesList
      this.statusVal = res.data.status;
      this.$refs.bidContent.innerHTML=this.bidContent
    })
  },

}
</script>

<style lang="scss" scoped>
.list{
  .content{
    width: 80%;
    margin: 10px;
    padding: 30px;
    background-color: #fff;

    .bidContent{
      p{
        margin-bottom: 10px;
      }
    }

    .download{

      li{
        text-align: left;
        font-size: 14px;
        list-style: none;
        color: grey;
      }

      li:hover {
        color: #13B69F;
        cursor: pointer;
      }
    }
  }
}
</style>
